package com.im.services.handler;

import org.springframework.stereotype.Component;
import org.yeauty.pojo.Session;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@Component
public class SesssionManager {

    // 这个map中保持所有的在线用户
    private Map<String, Session> sessionMap = new ConcurrentHashMap<>();

    public void add(String token, Session session) {
        sessionMap.put(token, session);
    }

    public Session get(String token) {
        return sessionMap.get(token);
    }

    public void remove(String token) {
        sessionMap.remove(token);
    }
}
